From: Dylan McCall Date: Mon, 29 Nov 2021 00:19:35 +0000 (-0800) Subject: messageList: Give focus to next message on delete X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~536^2^2~57 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4a23ddffa8094ef9bef9aefaef1eb23531d652de;p=gnome-shell.git messageList: Give focus to next message on delete When the user deletes a message using the keyboard, set the keyboard focus to the next message, or to the list container itself, so it remains possible to navigate using the keyboard. Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/502 Part-of: --- diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 8ffdaebc1..77672a592 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -663,12 +663,24 @@ var MessageListSection = GObject.registerClass({ } removeMessage(message, animate) { - if (!this._messages.includes(message)) + const messages = this._messages; + + if (!messages.includes(message)) throw new Error(`Impossible to remove untracked message`); let listItem = message.get_parent(); listItem._connectionsIds.forEach(id => message.disconnect(id)); + let nextMessage = null; + + if (message.has_key_focus()) { + const index = messages.indexOf(message); + nextMessage = + messages[index + 1] || + messages[index - 1] || + this._list; + } + if (animate) { listItem.ease({ scale_x: 0, @@ -677,10 +689,12 @@ var MessageListSection = GObject.registerClass({ mode: Clutter.AnimationMode.EASE_OUT_QUAD, onComplete: () => { listItem.destroy(); + nextMessage?.grab_key_focus(); }, }); } else { listItem.destroy(); + nextMessage?.grab_key_focus(); } }